package cn.iocoder.yudao.module.member.dal.mysql.order;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.order.OrderDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.order.vo.*;

/**
 * 订单 Mapper
 *
 * @author 家政
 */
@Mapper
public interface ApiOrderMapper extends BaseMapperX<OrderDO> {

    default PageResult<OrderDO> selectPage(OrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderDO>()
                .eqIfPresent(OrderDO::getUserId, reqVO.getUserId())
                .likeIfPresent(OrderDO::getOrderSn, reqVO.getOrderSn())
                .eqIfPresent(OrderDO::getOrderStatus, reqVO.getOrderStatus())
                .eqIfPresent(OrderDO::getMessage, reqVO.getMessage())
                .eqIfPresent(OrderDO::getGoodsPrice, reqVO.getGoodsPrice())
                .betweenIfPresent(OrderDO::getBeginTime, reqVO.getBeginTime())
                .betweenIfPresent(OrderDO::getEndTime, reqVO.getEndTime())
                .betweenIfPresent(OrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderDO::getId));
    }

}